package protocol

import (
	"JoRedis/constant"
	"strconv"
)

type BulkReply struct {
	ArgBytes []byte
}

func MakeBulkReply(argBytes []byte) *BulkReply {
	return &BulkReply{ArgBytes: argBytes}
}

func (this *BulkReply) ToBytes() []byte {
	if this.ArgBytes == nil {
		nullBulkReplyPtr := &NullBulkReply{}
		return nullBulkReplyPtr.ToBytes()
	}
	return []byte("$" + strconv.Itoa(len(this.ArgBytes)) + constant.CRLF + string(this.ArgBytes) + constant.CRLF)
}
